package com.startdima.user.infrastructure.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import com.startdima.user.infrastructure.interceptor.AppInterceptor;

import lombok.extern.slf4j.Slf4j;

@Configuration
@Slf4j
public class WebConfig implements WebMvcConfigurer {
 
    @Autowired
    private AppInterceptor appInterceptor;
 
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        log.info("addInterceptors---------------");
 
        // 注册拦截器
        InterceptorRegistration ir = registry.addInterceptor(appInterceptor);
        
        // 配置不拦截的路径
        ir.excludePathPatterns("/app/user/login");
 
        // 配置拦截的路径
        ir.addPathPatterns("/**");
 

    }
    
}